﻿using System;
using System.Text;
using Entities.DataBase;
using WebService.Service.Transfer;

namespace WebService.Email {
    
    public class CreatePurchaseListTemplate : BaseTemplate {

        public CreatePurchaseListRequest Request { get; set; }

        public new string Subject {
            get {
                return "新的购买列表 - " + DateTime.Now.ToLongDateString();
            }
        }

        public override string GenerateBody() {
            var customer = Services.Locate<ICustomerRepository>().Get(Request.CustomerId);
            var builder = new StringBuilder();
            builder.Append("<strong>" + Name + " 刚刚创建了一个新的购买列表!</strong>");
            builder.Append("<br/>");
            builder.Append("<strong>客户姓名 :</strong>" + customer.CName);
            builder.Append("<strong>客户电话 ：<strong>" + customer.PhoneNumber1);
            builder.Append("<br/>");
            builder.Append("<strong>客户地址 :<strong>");
            builder.Append(customer.Address1);
            builder.Append("<br/>");
            Request.PurchaseItems.ForEach(item => {
                builder.Append("<strong>产品名称 :</strong>" + item.ProductName + "&nbps;&nbps;<strong>数量 :</strong>" + item.Count);
                builder.Append("<br/>");
            });
            return builder.ToString();
        }
      
    }
}